package com.autoglm.android.core.models

import com.google.gson.Gson
import com.google.gson.annotations.SerializedName

/**
 * 用户意图，表示用户想要执行的操作
 */
data class UserIntent(
    @SerializedName("targetApp") val targetApp: String,
    @SerializedName("action") val action: String,
    @SerializedName("location") val location: String? = null,
    @SerializedName("displayMode") val displayMode: String? = null,
    @SerializedName("followUpActions") val followUpActions: List<String> = emptyList()
) {
    /**
     * 转换为描述性的字符串
     */
    fun toDescriptiveString(): String {
        val sb = StringBuilder("$action $targetApp")
        location?.let { sb.append(" 到 $it") }
        displayMode?.let { sb.append("，切换到$it") }
        if (followUpActions.isNotEmpty()) {
            sb.append("，然后 ${followUpActions.joinToString("、")}")
        }
        return sb.toString()
    }
    
    /**
     * 转换为JSON字符串
     */
    fun toJson(): String {
        return Gson().toJson(this)
    }
    
    companion object {
        /**
         * 从JSON字符串解析
         */
        fun fromJson(json: String): UserIntent {
            return Gson().fromJson(json, UserIntent::class.java)
        }
    }
} 